#ifndef     __TUBE_H
#define     __TUBE_H

#include "../utils/object.h"
#include "../utils/no_copyable.h"
#include "../utils/error.h"
#include "../utils/motor_ctrl.h"

namespace driver {

class Tube : utils::no_copyable_t, 
    public utils::MotorCtrl<Tube, 100, 15, 100, 20 * 1000> 
{
public:
    enum class dir_t {
        Down = 0,
        Up = 1,
        Brake = 2,
    };

    Tube();

    utils::error_t down(uint16_t speed, uint16_t steps);
    utils::error_t draw(uint16_t speed, uint16_t steps);
    utils::error_t up(uint16_t speed, uint16_t steps);

    utils::error_t down(uint16_t steps);
    utils::error_t draw(uint16_t steps);
    utils::error_t up(uint16_t steps);

    utils::error_t reset();

    static void set_target_speed(uint16_t speed);
    static uint16_t get_target_speed();

    static void test(dir_t dir, uint8_t sp);
    static uint16_t get_count();
    static void reset_count(); 
    static void set_voltage(uint8_t speed);

private:
    static void set_dir(dir_t dir);

};

inline utils::object_t<Tube> tube;

}


#endif
